package com.hptpd.questionnairesurvey.repository;

import com.hptpd.questionnairesurvey.domain.Choice;
import com.hptpd.questionnairesurvey.domain.question.BaseQuestion;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author YMHUI
 */
@Repository("choiceRep")
public interface ChoiceRep extends JpaRepository<Choice, String> {
    Choice getChoiceById(String id);

    /**
     * 查询问题中分数最高的选项
     *
     * @param question BaseQuestion
     * @return Choice
     */
    Choice findTopByBaseQuestionOrderByScoreDesc(BaseQuestion question);

    /**
     * 根据问题查询选项
     *
     * @param baseQuestion
     * @return
     */
    List<Choice> findChoicesByBaseQuestion(BaseQuestion baseQuestion);
}
